// components/wuliu/index.js
import api from "../../utils/api";
import apiLib from '../../utils/api_lib_method'

Component({
    options: {
        addGlobalClass: true,
    },
    properties: {
        orderid: {
            type: String,
            value: null,
            observer(newVal) {
                this.getWuliuList(newVal)
            }
        }
    },
    data: {
        progress: [],
        goods: {}
    },
    methods: {
        // 获取物流
        getWuliuList(id) {
            apiLib.apiGetWuliu(id).then(list => {
                console.log(list)
                // this.setData({
                //     progress: list,
                // })
            }).catch(e => {
                console.log('物流信息获取失败')
            })
        },
        // 确认收货
        okOrderSh(e) {
            let orderId = this.data.orderId
            let url = '/api/boardorder/confirm/' + orderId
            let text = '收货'
            apiLib.apiOkOrderShAndQxdd({url, text}).then(res => {
                this.triggerEvent('qrsh')
            })
        },
        // 取消订单
        cancelOrder(e) {
            let orderId = this.data.orderId
            let url = '/api/boardorder/cancel/' + orderId
            let text = '取消订单'
            apiLib.apiOkOrderShAndQxdd({url, text}).then(res => {
                this.triggerEvent('qxdd')
            })
        },
    }
})
